/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.unitn.science.matr155863_148346_145963.bccastestore.items;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 *
 * @author berto
 */
public class Asta {

    private Integer id;
    private Integer buyerId;
    private Integer sellerId;
    private Integer productId;
    private Integer quantity;
    
    
    private Float start_price;
    private Float min_price;
    private Float min_increment;
    private Float shipping_price;
    private Float last_offer_price;
    
    private Date date;
    private Integer umId;
    private boolean annulled = false;
    private Product product;
    private User seller;
    private User buyer;
    
    public Asta(){
        
    }

    public Asta(Integer id, Integer buyerId, Integer sellerId, 
            Integer productId, Integer quantity,
            Float start_price, Float min_price, Float min_increment, 
            Float shipping_price, Float last_offer_price, 
            Date date, Integer umId, boolean annulled,
            Product product) {
        this.id = id;
        this.buyerId = buyerId;
        this.sellerId = sellerId;
        this.productId = productId;
        this.quantity = quantity;
        this.start_price = start_price;
        this.min_price = min_price;
        this.min_increment = min_increment;
        this.shipping_price = shipping_price;
        this.last_offer_price = last_offer_price;
        this.date = date;
        this.umId = umId;
        this.annulled=annulled;
        this.product = product;
    }

    public void setProduct(Product product) {
        this.product = product;
        umId=product.getUmId();
    }

    
    public Float getLast_offer_price() {
        return last_offer_price;
    }

    public void setLast_offer_price(Float last_offer_price) {
        this.last_offer_price = last_offer_price;
    }

    public Float getMin_increment() {
        return min_increment;
    }

    public void setMin_increment(Float min_increment) {
        this.min_increment = min_increment;
    }

    public Float getMin_price() {
        return min_price;
    }

    public void setMin_price(Float min_price) {
        this.min_price = min_price;
    }

    public Float getStart_price() {
        return start_price;
    }

    public void setStart_price(Float start_price) {
        this.start_price = start_price;
    }
    
    public Integer getBuyerId() {
        return buyerId;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    
    public void setBuyerId(Integer buyerId) {
        this.buyerId = buyerId;
    }
    
    public Float getMinimumValidOffer(){
        if (this.last_offer_price==0){
            return this.start_price;
        }else{
            return this.last_offer_price+this.min_increment;
        }
    }

    public Integer getSellerId() {
        return sellerId;
    }

    public void setSellerId(Integer sellerId) {
        this.sellerId = sellerId;
    }

    public Float getShipping_price() {
        return shipping_price;
    }

    public void setShipping_price(Float shipping_price) {
        this.shipping_price = shipping_price;
    }

    public Integer getUmId() {
        return umId;
    }

    public void setUmId(Integer umId) {
        this.umId = umId;
    }
    
    public String getBill() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public Integer getId() {
        return id;
    }
    public void setId(int id) {
        this.id= id;
    }
    
    public User getBuyer() {
        return buyer;
    }
    
    public void setBuyer(User buyer) {
        this.buyer = buyer;
    }
    
    public User getSeller() {
        return seller;
    }
    
    public void setSeller(User sel) {
        seller = sel;
    }

    public Date getDate() {
        return date;
    }
    
    public void setDate(Date dat) {
        date=dat;
    }

    public Integer getProductId() {
        return productId;
    }
    
    public void setProductId(Integer pro) {
        productId=pro;
    }
    
    public Float getUmName() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    
    public Float getShippingPrice() {
        return shipping_price;
    }
     
    public void setShippingPrice(Float shPr) {
        shipping_price=shPr;
    }
    
    public Integer getQuantity() {
        return quantity;
    }
    
    public void setQuantity(Integer quan) {
        quantity=quan;
    }

    public void setUm(Integer umId) {
        this.umId = umId;
    }

    public void setAnnulled(boolean b) {
        annulled=b;
    }

    public int getUm() {
        return umId;
    }

    public boolean getAnnulled() {
        return annulled;
    }


    public Product getProduct() {
        return product;
    }
    
    public String getHumanDeadline(){
        SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss",Locale.ITALIAN);
            sf.setLenient(false);
            return sf.format(date);
    }
}
